﻿using ChiWalker.Dynamics;
using ChiWalker.Helpers;
using ChiWalker.Spell;
using ChiWalker.Utilities;
using Styx;
using Styx.TreeSharp;

namespace ChiWalker.Routines.Hunter
{
    internal class Marksman
    {
        [Behavior(BehaviorType.Combat | BehaviorType.Pull)]
        [Spec(WoWSpec.HunterMarksmanship)]
        [Class(WoWClass.Hunter)]
        public static Composite MarksmanHunter()
        {
            return new PrioritySelector(
                Safers.EnsureTarget(),
                WaitFor.WaitForCast(),
                Movement.MoveToLoS(ret => StyxWoW.Me.CurrentTarget),
                Movement.FaceMyTarget(),
                Pet.CreatPetBehavoir(),
                new CastOnMyTarget(Spell.KillShot),
                new Decorator(
                    ret =>
                        Clusters.GetClusterCount(StyxWoW.Me.CurrentTarget, Clusters.NearbyUnitsInCombatWithMe,
                            ClusterType.Radius, 10f) >= 4,
                    new PrioritySelector(
                        new CastAtLocation(Spell.ExplosiveTrap, ret => StyxWoW.Me.CurrentTarget.Location,
                            ret => StyxWoW.Me.HasAura(Spell.TrapLauncher)),
                        new CastOnMyTarget(Spell.MultiShot),
                        new CastOnMyTarget(Spell.SteadyShot)
                        )
                    ),
                new CastOnMyTarget(Spell.SerpentSting, ret => !StyxWoW.Me.CurrentTarget.HasMyAura(Aura.SerpentSting),
                    null, true),
                new CastOnMyTarget(Spell.ChimeraShot),
                new CastOnMyTarget(Spell.AimedShot, ret => StyxWoW.Me.HasAura(Aura.Fire), null, true),
                new CastOnMyTarget(Spell.SteadyShot,
                    ret => StyxWoW.Me.GetAuraTimeLeft(Aura.SteadyFocus, true).TotalSeconds <= 4),
                new CastOnMyTarget(Spell.DireBeast),
                new CastOnMyTarget(Spell.GlaiveToss),
                new CastOnMyTarget(Spell.Readiness, ret => StyxWoW.Me.CurrentTarget.IsJournalBoss()),
                new CastOnMyTarget(Spell.ArcaneShot, ret => StyxWoW.Me.FocusPercent >= 45),
                new CastOnMyTarget(Spell.SteadyShot),
                Movement.MoveToUnit(ret => StyxWoW.Me.CurrentTarget, ret => 40f)
                );
        }
    }
}